package com.ruoyi.project.mahjong.service.impl;

import java.util.List;

import cn.hutool.core.util.ObjectUtil;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.mahjong.mapper.TRoomMapper;
import com.ruoyi.project.mahjong.domain.TRoom;
import com.ruoyi.project.mahjong.service.ITRoomService;

/**
 * 房间Service业务层处理
 *
 * @author ruoyi
 * @date 2023-10-07
 */
@Service
public class TRoomServiceImpl implements ITRoomService
{
    @Autowired
    private TRoomMapper tRoomMapper;

    /**
     * 查询房间
     *
     * @param id 房间ID
     * @return 房间
     */
    @Override
    public TRoom selectTRoomById(Long id)
    {
        return tRoomMapper.selectTRoomById(id);
    }

    /**
     * 查询房间列表
     *
     * @param tRoom 房间
     * @return 房间
     */
    @Override
    public List<TRoom> selectTRoomList(TRoom tRoom)
    {
        return tRoomMapper.selectTRoomList(tRoom);
    }

    /**
     * 新增房间
     *
     * @param tRoom 房间
     * @return 结果
     */
    @Override
    public int insertTRoom(TRoom tRoom)
    {
        tRoom.setCreateTime(DateUtils.getNowDate());
        return tRoomMapper.insertTRoom(tRoom);
    }

    /**
     * 修改房间
     *
     * @param tRoom 房间
     * @return 结果
     */
    @Override
    public int updateTRoom(TRoom tRoom)
    {
        tRoom.setUpdateTime(DateUtils.getNowDate());
        return tRoomMapper.updateTRoom(tRoom);
    }

    /**
     * 批量删除房间
     *
     * @param ids 需要删除的房间ID
     * @return 结果
     */
    @Override
    public int deleteTRoomByIds(Long[] ids)
    {
        return tRoomMapper.deleteTRoomByIds(ids);
    }

    /**
     * 删除房间信息
     *
     * @param id 房间ID
     * @return 结果
     */
    @Override
    public int deleteTRoomById(Long id)
    {
        return tRoomMapper.deleteTRoomById(id);
    }

    @Override
    public boolean checkRoom(Long shopId, String roomName) {
       TRoom room=new TRoom();
       room.setBak1(shopId.toString());
       room.setRoomName(roomName);
       List<TRoom> roomList=selectTRoomList(room);

        return ObjectUtil.isEmpty(roomList)?true:false;
    }

    @Override
    public List<TRoom> selectRoomListByShopId(Long shopId) {
        return tRoomMapper.selectRoomListByShopId(shopId);
    }
}
